gdk/wayland/surface: Use dedicated bool for frame callback freezing
authorJonas Ådahl <jadahl@gmail.com>
Tue, 10 Dec 2019 18:23:17 +0000 (19:23 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Wed, 19 Feb 2020 08:47:18 +0000 (09:47 +0100)
The freezing is conditioned on various state, so lets make the thawing a
bit more robust. Without this there was a risk that we'd thaw too many
times if there was a frame callback requested while the conditions for
the freezing were not met.

gdk/wayland/gdksurface-wayland.c

index b3608dab3bedf178aa4e72e67f03a82c73164abf..02409da4e70bf2017b5165951fb474207378cce5 100644 (file)
@@ -85,6 +85,7 @@ struct _GdkWaylandSurface
   unsigned int mapped : 1;
   unsigned int pending_commit : 1;
   unsigned int awaiting_frame : 1;
+  unsigned int awaiting_frame_frozen : 1;
   GdkSurfaceTypeHint hint;
   GdkSurface *transient_for;
   GdkSurface *popup_parent;
@@ -362,7 +363,11 @@ frame_callback (void               *data,
     return;
 
   impl->awaiting_frame = FALSE;
-  gdk_surface_thaw_updates (surface);
+  if (impl->awaiting_frame_frozen)
+    {
+      impl->awaiting_frame_frozen = FALSE;
+      gdk_surface_thaw_updates (surface);
+    }
 
   timings = gdk_frame_clock_get_timings (clock, impl->pending_frame_counter);
   impl->pending_frame_counter = 0;
@@ -481,7 +486,10 @@ on_frame_clock_after_paint (GdkFrameClock *clock,
 
   if (impl->awaiting_frame &&
       impl->pending_frame_counter == gdk_frame_clock_get_frame_counter (clock))
-    gdk_surface_freeze_updates (surface);
+    {
+      impl->awaiting_frame_frozen = TRUE;
+      gdk_surface_freeze_updates (surface);
+    }
 }
 
 void
@@ -2570,9 +2578,10 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
             impl->initial_configure_received = FALSE;
         }
 
-      if (impl->awaiting_frame)
+      impl->awaiting_frame = FALSE;
+      if (impl->awaiting_frame_frozen)
         {
-          impl->awaiting_frame = FALSE;
+          impl->awaiting_frame_frozen = FALSE;
           gdk_surface_thaw_updates (surface);
         }